proc useradd {nick handle chan otbn1 host otbn tcl} {
global home botnick bcast
 if {$otbn1 == ""} {
  putserv "NOTICE $nick :ERROR - Invalid Syntax - Should Be - (/msg) $botnick useradd <nick> <#channel> <level>"
  return 0
  }
 if {$otbn == ""} {
  putserv "NOTICE $nick :ERROR - Unknown Level - use one of these levels: avoice,aop,op,ccadmin,cadmin,bop,bcadmin,root"
  return 0
  }
 if {![onchan $otbn1 $chan]} {
  putserv "NOTICE $nick :ERROR - $otbn1 not found on $chan"
  return 0
  }
  set hostname [getchanhost $otbn1 $chan]
if {[string match "~*" $hostname]} {
  set hostname [string range $hostname 1 end]
  }
  set dhost [maskhost *$hostname]
  set hand2 [nick2hand $otbn1 $chan]
  set otbn [string tolower $otbn]
  set newuser 0
if {[string match {avoice} $otbn] == 1 } {  
if {![matchattr $handle o|m $chan]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 |+f $chan]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' in $chan - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $chan $otbn1 avoice"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd \002$otbn1\002 into my user partition in channel record: '$chan'. Level: AutoVoice."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Channel\002: $chan"
  putserv "NOTICE $otbn1 :\002Level\002: AutoVoice"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost" 
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Channel\002: $chan"
  putserv "NOTICE $nick :\002Level\002: AutoVoice"
  putserv "NOTICE $nick :\002Host\002: $dhost"		
  chattr [nick2hand $otbn1 $chan] |+vf $chan
  chattr [nick2hand $otbn1 $chan] +hp
  save
  return 0
  }
if {[string match {op} $otbn] == 1 } {
if {![matchattr $handle o|m $chan]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 |+f $chan]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' in $chan - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $chan $otbn1 op"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my user partition in channel record '$chan'. Level: Channel Operator."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Channel\002: $chan"
  putserv "NOTICE $otbn1 :\002Level\002: Channel Operator"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Channel\002: $chan"
  putserv "NOTICE $nick :\002Level\002: Channel Operator"
  putserv "NOTICE $nick :\002Host\002: $dhost"
   chattr [nick2hand $otbn1 $chan] |+of $chan
   chattr [nick2hand $otbn1 $chan] +hp
   save
   }
if {[string match {ccadmin} $otbn] == 1 } {
if {![matchattr $handle o|n $chan]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 |+f $chan]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' in $chan - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $chan $otbn1 ccadmin"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd \002$otbn1\002 into my user partition in channel record '$chan'. Level: Channel Co-Administrator."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Channel\002: $chan"
  putserv "NOTICE $otbn1 :\002Level\002: Channel Co-Administrator"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost" 
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."  
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002" 
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Channel\002: $chan"
  putserv "NOTICE $nick :\002Level\002: Channel Co-Administrator"
  putserv "NOTICE $nick :\002Host\002: $dhost"		
  chattr [nick2hand $otbn1 $chan] |+fmo $chan
  chattr [nick2hand $otbn1 $chan] +hp
  save
  }
if {[string match {cadmin} $otbn] == 1 } {
if {![matchattr $handle o]} {
  putserv "notice $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 |+f $chan]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' in $chan - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $chan $otbn1 cadmin"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my user partition in channel record '$chan'. Level: Channel Administrator."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Channel\002: $chan"
  putserv "NOTICE $otbn1 :\002Level\002: Channel Administrator"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Channel\002: $chan"
  putserv "NOTICE $nick :\002Level\002: Channel Administrator"
  putserv "NOTICE $nick :\002Host\002: $dhost"
    chattr [nick2hand $otbn1 $chan] |+fmno $chan
    chattr [nick2hand $otbn1 $chan] +hp
    save
    }
if {[string match {bop} $otbn] == 1} {
if {![matchattr $handle m]} { 
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 +f]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $otbn1 bop"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my user partition. Level: BotNet Operator."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Level\002: BotNet Operator"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."  
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Level\002: BotNet Operator"
  putserv "NOTICE $nick :\002Host\002: $dhost"
    chattr [nick2hand $otbn1 $chan] +ofpxh
    save
    }
if {[string match {bcadmin} $otbn] == 1 } {
if {![matchattr $handle n]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 +f]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $otbn1 bcadmin"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my user partition. Level: BotNet Co-Administrator."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Level\002: BotNet Co-Administrator"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Level\002: BotNet Co-Administrator"
  putserv "NOTICE $nick :\002Host\002: $dhost"
  chattr [nick2hand $otbn1 $chan] +fhjmoptx
  save
  }
if {[string match {root} $otbn] == 1 } {
if {![matchattr $handle n]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 +f]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1
  }
  putlog "!$nick ($host)! useradd $otbn1 root"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my root partition. Level: BotNet Administrator."
  }
  putserv "NOTICE $otbn1 :You have been added into my root partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Level\002: BotNet Administrator (root)"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Level\002: BotNet Administrator (root)"
  putserv "NOTICE $nick :\002Host\002: $dhost"
    chattr [nick2hand $otbn1 $chan] +fhjmnoptx
    save
    }
if {[string match {aop} $otbn] == 1 } {
if {![matchattr $handle o|m $chan]} {
  putserv "NOTICE $nick :Unable To Execute Command - Permission Denied."
  return 0
  }
if {[matchattr $otbn1 |+f $chan]} {
  putserv "NOTICE $nick :ERROR - Unable to add user - the user $otbn1 currently exsists' in $chan - try using the usermod command."
  return 0
  }
if {![validuser $hand2]} {
  adduser $otbn1 $dhost
  set newuser 1 
  }
  putlog "!$nick ($host)! useradd $chan $otbn1 aop"
if {$bcast == "1"} {
  putserv "PRIVMSG $home :\002$nick\002 ($host) requested me to useradd $otbn1 into my user partition in channel record '$chan' Level: AutoOp."
  }
  putserv "NOTICE $otbn1 :You have been added into my user partition by: \002$nick\002"
  putserv "NOTICE $otbn1 :Info Follows...."
  putserv "NOTICE $otbn1 :\002Your ID\002: $otbn1"
  putserv "NOTICE $otbn1 :\002Channel\002: $chan"
  putserv "NOTICE $otbn1 :\002Level\002: AutoOp"
  putserv "NOTICE $otbn1 :\002Host\002: $dhost"
if {$newuser == 0} {
  putserv "NOTICE $otbn1 :You currently have a password set - type \002/msg $botnick auth <password>\002 to login."
  }
if {$newuser == 1} {
  putserv "NOTICE $otbn1 :You \002!MUST!\002 set a password for future identification purposes.You will need this password to log in every time you want to use the bot by typing \002/msg $botnick auth <password>\002"
  putserv "NOTICE $otbn1 :You may do so by typing \002/msg $botnick pass <password>\002"
  }
  putserv "NOTICE $nick :Sucessfully Added:"
  putserv "NOTICE $nick :\002ID\002: $otbn1"
  putserv "NOTICE $nick :\002Nick\002: $otbn1"
  putserv "NOTICE $nick :\002Channel\002: $chan"
  putserv "NOTICE $nick :\002Level\002: AutoOp"
  putserv "NOTICE $nick :\002Host\002: $dhost"
    chattr [nick2hand $otbn1 $chan] |+fa $chan
    save
    }
    }


